//导入request.js
import request from "@/common/index.js";


let commonPayload = () => {
	let userInfo = uni.getStorageSync('userInfo');
	userInfo = userInfo && JSON.parse(userInfo);
	return {
		timestamp: Math.round(new Date().getTime() / 1000).toString(),
		hash: 'acbcefg',
		user_id: (userInfo && userInfo.user_id) || 0
	}
}
//登录
// export const login = (params) => request.post("/api/login",{params});
//获取个人信息
// export const userDetail = (params) => request.get("/api/user/detail",{params});

//注册
export const register = async (params) => {
	const res = await request.post(`/api/register`, params);
	return res.data;
};
//登录
export const login = async (params) => {
	const res = await request.post(`/api/login`, params);
	return res.data;
};
//删除公式
export const delFormula = async (params) => {
	const res = await request.post(`/api/delete_formula`, params);
	return res.data;
};

//编辑公式
export const setFormula = async (params) => {
	const res = await request.post(`/api/update_formula`, params);
	return res.data;
};

// 报价单列表页
export const request_quotation = async (params) => {
	const res = await request.post(`/api/request_quotation`, {
		...commonPayload(),
		...params
	});
	return res.data;
};
export const delete_quotation = async (params) => {
	const res = await request.post(`/api/delete_quotation`, {
		...commonPayload(),
		...params
	});
	return res.data;
};
// 添加报价单
export const add_quotation = async (params) => {
	const res = await request.post(`/api/add_quotation`, params);
	return res.data;
};

//报价记录
export const updateCompany = async (params) => {
	const res = await request.post(`/api/update_company`, params);
	return res.data;
};